{
  "properties" : { },
  "id" : "44479f1fa4fa4930971c5bd9377118b3",
  "script" : null,
  "groupId" : "09cead823dff4c70b2f24035bd170cf5",
  "name" : "抓取网站",
  "createTime" : null,
  "updateTime" : 1741279087890,
  "lock" : null,
  "createBy" : null,
  "updateBy" : "管理员",
  "path" : "zqwz",
  "method" : "GET",
  "parameters" : [ ],
  "options" : [ ],
  "requestBody" : "",
  "headers" : [ ],
  "paths" : [ ],
  "responseBody" : "{\n    \"code\": 500,\n    \"msg\": \"系统内部出现错误\"\n}",
  "description" : null,
  "requestBodyDefinition" : null,
  "responseBodyDefinition" : null
}
================================
import org.openqa.selenium.OutputType;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.Cookie;
import org.ssssssss.magicapi.utils.IoUtils;
import com.wiwf.model.manage.utils.SeleniumUtil;
import java.io.File
import response
import http;
import log;

FirefoxDriver driver = SeleniumUtil.getFoxDriver("/data/spider/file/geckodriver.exe");

try {

    for (idx in [2,1]) {
        
        var url = "https://www.test.com/game/page/"+idx;

            // -- 访问
            driver.get(url);
            // -- 动作
            weAct = new Actions(driver); weAct.pause(6*1000); weAct.perform();
            //
            driver.executeScript('window.scrollTo(0,3000)',driver.findElementsByTagName('body'))
            
            // -- 取元素 
            var wes = driver.findElements(By.xpath('//*[@id="content"]/div/div/div[2]/div/div/div[2]/div[1]/h2/a'));
            
            var idxx = 0;
            for (webObj in wes) {
                idxx = idxx + 1;
                //
                driver.executeScript('window.scrollTo(0,'+(idxx*200)+')',driver.findElementsByTagName('body'))
                weAct = new Actions(driver);
                weAct.pause(1*1000);
                weAct.perform();

                var title = webObj.getText();
                var page = webObj.getAttribute('href');
                // 
                var webImg = driver.findElement(By.xpath('//*[@id="content"]/div[1]/div/div[2]/div['+idxx+']/div/div[1]/a')).getScreenshotAs(OutputType.BYTES);

                try {
                    var tag1 = title.toString().split("【")[1].split("】")[0];
                    var tag2 = title.toString().split("【")[2].split("】")[0];
                    var name = title.toString().split("【")[1].split("】")[1].trim();

                    // href
                    var uri = now().getTime()+'.png';

                    var inputFile = new File('/work/my_boot/web-manage/src/static/img/acgimg/'+uri);
                    IoUtils.write(inputFile, webImg);

                    db.table('ct_acggame').where().eq('name', name).delete();
                    var idVal = db.table('ct_acggame').primary('id').insert({'name': name,'page': page,'img': uri,'tag1': tag1,'tag2': tag2});
                    log.info("id {}", idVal);
                } catch(e) {
                    continue;
                }
            }

    }


} finally {
    // -- 结束
    driver.close();
}

return 1;